<link href="<?php echo URL::base() ?>media/vendor/css/ui-lightness/jquery-ui-1.10.4.custom.css" rel="stylesheet">
<script src="<?php echo URL::base() ?>media/vendor/js/jquery-1.7.1.min.js"></script>
<script src="<?php echo URL::base() ?>media/vendor/js/jquery.ui.core.min.js"></script>
<script src="<?php echo URL::base() ?>media/vendor/js/jquery.ui.widget.min.js"></script>
<script src="<?php echo URL::base() ?>media/vendor/js/jquery.ui.position.min.js"></script>
<script src="<?php echo URL::base() ?>media/vendor/js/jquery.ui.autocomplete.min.js"></script>
<script src="<?php echo URL::base() ?>media/vendor/js/jquery-1.7.1.min.js"></script>
<script src="<?php echo URL::base() ?>media/vendor/js/jquery-ui-1.10.4.custom.js"></script>
<script src="<?php echo URL::base() ?>media/vendor/js/jquery-ui-timepicker-addon.min.js"></script>
<script src="<?php echo URL::base() ?>media/vendor/js/jquery-ui-timepicker-zh-CN.js"></script>
<script src="<?php echo URL::base() ?>media/vendor/js/jquery.ui.datepicker-zh-TW.js"></script>
<script src="<?php echo URL::base() ?>media/vendor/js/Validform_v5.3.2_ncr_min.js"></script>
<script src="<?php echo URL::base() ?>media/vendor/artdialog/jquery.artDialog.js"></script>
<form action="<?php echo url::base(TRUE) . 'checkstandard/index'; ?>" method="get" name="form" onsubmit="return checkForm();" class="form-horizontal">
    <div class="control-group">
        <lable class="control-label"> 批次号：</lable>
        <div class="controls">
        <input type='text' name="batch_code" value="<?php echo $batch_code; ?>" id="batch_code" autocomplete="off">
        </div>
    </div>
    <div class="control-group">
        <lable class="control-label">收货明细号：</lable>
        <div class="controls">
        <input type='text' name="recieve_details_id" value="<?php echo isset($recieve_details_id) && $recieve_details_id ? $recieve_details_id : ''; ?>">&nbsp;&nbsp;
        </div>
    </div>
    <div class="control-group">
         <div class="controls">
            <input type='submit' name='sub' value='查询' class="btn btn-info">
        </div>
    </div>
</form>
    <?php if(isset($recieve_infos)){?>
    <table class="table table1">
        <thead>
        <tr>
            <th><input type="checkbox" id="checkAllBtn">全选</th>
            <th>
                批次号
            </th>
            <th>
                收货明细号
            </th>
            <th>
                收货人
            </th>
            <th>
                VMI预约单号
            </th>
            <th>
                计划员
            </th>
            <th>跟单员</th>
            <th>
                SKU
            </th>
            <th>
                SKU名称
            </th>
            <th>
                质检标准
            </th>
        </tr>
        </thead>
        <tbody>

        <?php foreach($recieve_infos as $recieve_info){?>
            <tr>
                <td>
                    <input type="checkbox" value="<?php echo $recieve_info['id'];?>" <?php if($recieve_info['skuchecksign'] == 10) {?>class="tocheck" <?php } else { echo "disabled = 'disabled'";}?>/>
                </td>
                <td>
                    <?php echo $recieve_info['batch_code'];?>
                </td>
                <td>
                    <?php echo $recieve_info['id'] ?>
                </td>
                <td>
                    <?php echo $recieve_info['recieve_man'] ?>
                </td>
                <td>
                    <?php echo $recieve_info['purchaseorder_id'] ?>
                </td>

                <td>
                    <?php echo $recieve_info['purchase_man'] ?>
                </td>
                <td>跟单名字</td>
                <td>
                    <?php echo $recieve_info['sku'] ?>
                </td>
                <td>
                    <?php echo $recieve_info['sku_name'] ?>
                </td>
                <td>
                    <?php $a=1;
                    foreach($recieve_info['skucheckdetails'] as $id=>$skucheckdetail){
                        echo $skucheckdetail.'<br/>';
                        $a++;
                    }
                    ?>
                </td>

            </tr>
        <?php }
        } ?>
        </tbody>
        <tfoot><tr><td colspan="10" style="text-align: left">
            <?php if(isset($recieve_infos)){?>
                <button class="btn btn-info" id="checkStandardMore">批量确认</button>
            <?php } ?>
            </td></tr></tfoot>
    </table>

<script type="text/javascript">
    $(document).ready(function () {
        $("#checkAllBtn").click(function(){
            if(this.checked == true)
            {
                $(".tocheck").each(function(){
                    this.checked = true;
                });
            }
            else
            {
                $(".tocheck").each(function(){
                    this.checked = false;
                });
            }
        });

        $("#checkStandardMore").click(function(){
            var receiptDetailIds = Array();
            $(".tocheck").each(function(){
                if(this.checked==true){
                    receiptDetailIds.push($(this).val());
                }
            });
            if(!receiptDetailIds.length){alert('请选择');return;}


            $.ajax({
                type:'post',
                url:'<?php echo url::base(true);?>checkstandard/checkStandardMore',
                dataType:'json',
                data:{'receiptDetailIds' : receiptDetailIds},
                async:false,
                success:function(data)
                {
                    alert('确认成功');
                    window.location.href=window.location.href;
                    window.location.reload;
                },
                error:function(){
                    alert("error");
                }
            });

        });

        $("#batch_code").autocomplete({
            autoFocus: true,
            minLength: 0,
            autoFill: true,
            source: '<?php echo URL::base(true)?>quality/getBatchCode',
            select: function (event, ui) {
                /**
                 * 从建议列表中选中之后触发的事件
                 */
                $("#batch_code").val(ui.item.name);
                $("#batch_code").attr("readonly", "readonly");
                return false;
            }
        });
    });

    function checkForm(){
        var batch_code = form.batch_code.value;
        var batch_code = Number(batch_code);
        var recieve_details_id = form.recieve_details_id.value;
        var recieve_details_id = Number(recieve_details_id);
        if(isNaN(recieve_details_id) || isNaN(batch_code)){

            alert('非法输入！');
            return false;
        }
    }

</script>

